package Server;

import java.util.ArrayList;
import game.Player;


/**
 * This class represents a Game, as long as it is not full (less than 4 players) and it is not started.
 * Some other Class for a game may by created with the data of this class,
 * but mainly it is for the server to sort, whom is already in a game.
 * 
 * @author Balduin Landolt
 *
 */
public class GameServer implements Runnable {
	
	private ArrayList<ServerseitigerClient> players;
	private String name;
	private ServerseitigerClient createdBy;
	
	/**
	 * creats a new gameServer
	 * 
	 * @param name the games name
	 * @param creator the client whom has created the game
	 */
	public GameServer(String name, ServerseitigerClient creator) {
		this.name=name;
		createdBy=creator;
	}
	
	/**
	 * returns the players on this game server
	 * 
	 * @return the players
	 */
	public ArrayList<ServerseitigerClient> getPlayers() {
		return players;
	}

	/**
	 * Returns the name of this gameServer
	 * @return the name
	 */
	public String getName() {
		return name;
	}
	
	/**
	 * @return
	 */
	public ServerseitigerClient getCreator(){
		return createdBy;
	}

	public void run() {
		
	}
	
	/**
	 * @param player
	 */
	public void addPlayer(ServerseitigerClient player) {
		if(!players.contains(player)) {
			players.add(player);
		}
	}
	
	/**
	 * @param player
	 */
	public void removePlayer(Player player) {
		players.remove(player);
	}
	
	/**
	 * @return
	 */
	public int countPlayers()  {
		return players.size();
	}

}
